

<!--
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-12-09 06:20:51
 * @LastEditors: GGB
 * @LastEditTime: 2021-12-09 06:29:14
-->
<template>
    <!--vue3.0和Ts的模板 -->
    <!-- 新增待办 -->
    <input type="text" v-model="todoName" @keydown.enter="addTodo" />
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import { useStore } from "vuex"
import { key } from "../store";
const store = useStore(key)
const router = useRouter()
const todoName = ref("")
const addTodo = () => {
    store.dispatch('todos/addTodo', todoName.value);
    todoName.value = ""
    router.go(-1)
}
</script>

